package com.study.concurrent.A_ThreadManagement.h_HandlingOfUncontrollableExceptionsInThreads;

/**
 * Created by 赵超 on 2017/3/19.
 * 自定义未捕获异常处理器
 * 实现UncaughtExceptionHandler接口并重写uncaughtException方法
 */
public class ExceptionHandler implements Thread.UncaughtExceptionHandler {
    @Override
    public void uncaughtException(Thread t, Throwable e) {
        System.out.printf("捕获了一个异常\n");
        System.out.printf("线程ID : %s\n", t.getId());
        System.out.printf("异常 : %s : %s\n", e.getClass().getName(), e.getMessage());
        System.out.printf("堆栈跟踪 Stack Trace :\n");
        e.printStackTrace(System.out);
        System.out.printf("线程的状态 : %s\n", t.getState());
    }
}
